home *** CD-ROM | disk | FTP | other *** search
- ---------------------------
- -- Byte Magazine's --
- -- Prime Sieve Benchmark --
- ---------------------------
-
- without type_check -- makes no difference
-
- constant ITERATIONS = 1000
-
- constant SIZE = 8191,
- ON = 1,
- OFF = 0
-
- sequence flags
-
- global procedure main()
- integer prime, start, count, still_prime
- atom x
-
- x = time()
- for iter = 1 to ITERATIONS do
- count = 0
- flags = repeat(ON, SIZE)
- for i = 1 to SIZE do
- still_prime = flags[i]
- if still_prime then
- prime = i + i
- prime = prime + 1
- -- printf(1, "%d ", prime)
- start = prime + i
- for k = start to SIZE by prime do
- flags[k] = OFF
- end for
- count = count + 1
- end if
- end for
- end for
- printf(1, "%d primes\n", count) -- should be 1899
- printf(1, "%d iterations in %.2f seconds\n", {ITERATIONS, time() - x})
- end procedure
-
- main()
-
-